<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Endroid\QrCode\QrCode;
use Input;

class HelperController extends Controller{
	public function getQrcode($size=120){
		$qrtxt=Input::get('qrtxt');
		$qrCode = new QrCode();
        $qrCode->setText($qrtxt)
            ->setSize($size)
            ->setPadding(10)
            ->setErrorCorrection('high')
            ->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
            ->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))
            ->setLabelFontSize(16)
            ->render();
	}

    // public function getDosss(){
    //     // $res1=\App\Models\Windows::select('id','tagkey')->whereRaw('tagkey is not null')->get();
    //     // $res2=\App\Models\Android::select('id','tagkey')->whereRaw('tagkey is not null')->get();
    //     // $res3=\App\Models\Ios::select('id','tagkey')->whereRaw('tagkey is not null')->get();
    //     // $res4=\App\Models\Other::select('id','tagkey')->whereRaw('tagkey is not null')->get();
    //     // $res5=\App\Models\Article::select('id','tagkey')->whereRaw('tagkey is not null')->get();
    //     $taglist=\App\Models\Tag::all();
    //     foreach ($taglist as $key => $value) {
    //         $win=\App\Models\Article::select('id','tagkey')->where('tagkey','like','%'.$value->name.'%')->get();
    //         if($win){
    //             foreach ($win as $k => $v) {
    //                 $taggable = new \App\Models\Taggable;
    //                 $taggable->tag_id = $value->id;
    //                 $taggable->taggable_id = $v->id;
    //                 $taggable->taggable_type = 'App\Models\Article';
    //                 $res=$taggable->save();
    //             }
    //         }
    //     }
    //     dd('finish');
    //     // $arr=array();
    //     // foreach ($res1 as $key => $value) {
    //     //     array_push($arr,$value['tagkey']);
    //     // }
    //     // dd($arr);
    //     // $str=implode(',', $arr);
    //     // $newarr=explode(',', $str);
    //     // foreach ($newarr as $key => $value) {
    //     //     // array_push($arr,$value['tagkey']);
    //     //     $tmpp=new \App\Models\Tmpp;
    //     //     $tmpp->name=$id;
    //     //     $tmpp->name=$value;
    //     //     $isbool=$tmpp->save();
    //     // }
    //     // dd();
    // }

    // public function getSooo(){
    //     $soo=\DB::select('select DISTINCT(name) from xz_tmpp');
    //     foreach ($soo as $key => $value) {
    //         $res=\DB::insert('insert into xz_tmpp1 (name) values (?)', [$value->name]);
    //     }
    //     dd();
    //     dd($soo);
    // }

    // public function getDosss(){
    //     $res1=\App\Models\Zandroid1::select('tag')->get();
    //     $res2=\App\Models\Zios1::select('tag')->get();
    //     $res3=\App\Models\Zwins1::select('tag')->get();
    //     $res4=\App\Models\Zarticle1::select('tag')->get();
    //     $res5=\App\Models\Zother1::select('tag')->get();
    //     $arr=array();
    //     foreach ($res5 as $key => $value) {
    //         array_push($arr,$value['tag']);
    //     }
    //     $str=implode(',', $arr);
    //     $newarr=explode(',', $str);
    //     foreach ($newarr as $key => $value) {
    //         // array_push($arr,$value['tagkey']);
    //         $tmpp=new \App\Models\Tmppp;
    //         $tmpp->name=$value;
    //         $isbool=$tmpp->save();
    //     }
    //     dd();
    // }

    // public function getSooo(){
    //     $soo=\DB::select('select DISTINCT(name) from xz_tmppp');
    //     foreach ($soo as $key => $value) {
    //         $res=\DB::insert('insert into xz_tmppp1 (name) values (?)', [$value->name]);
    //     }
    //     dd();
    //     dd($soo);
    // }

    //  public function getGG(){
    //     $soo=\DB::select('select DISTINCT(name) from xz_tmppp');
    //     foreach ($soo as $key => $value) {
    //         $res=\DB::insert('insert into xz_tmppp1 (name) values (?)', [$value->name]);
    //     }
    //     dd();
    //     dd($soo);
    // }

    // public function getDosm(){
    //     $taglist=\App\Models\Tag::all();
    //     $util=new \App\Util\Util;
    //     foreach ($taglist as $key => $value) {
    //         $value->indexf = $util->getFirstCharter($value->name);
    //         $value->save();
    //     }
    // }
}
